
Rem
	Returns the portion of string specified by the start and length parameters.
	
	@author	Nicholas Grant
	@updatedby	
	
	@param	string	str
	@param	integer	start
	@param	integer	length
	
	@return	string
	@return	string containing null
End Rem
Function substr:String( str:String, start:Int, length:Int = 0)
	If ( start < 0 )
		start = str.Length + start;
	End If
	If ( Not length )
		length = str.Length - start;
	End If
	If ( length < 0 )
		length = str.Length + length - start;
		If ( ( start + length ) > str.Length )
			length = str.Length - start;
		End If
	End If
	If ( str.Length < start Or start < 0 Or ( start + length ) <= start  )
		Return "~0";
		' Returns false (0), but, this is BlitzMax, don't want to return wrong type
		' Use empty() to determine if the string returns null
	End If
	
	Return str[start..(start + length)]
End Function
